package com.sltx.controller;

import com.sltx.controller.base.BaseController;
import com.sltx.service.ModelService;
import com.sltx.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;


@Controller
@RequestMapping("/Model")
public class ModelController  extends BaseController {

    @Autowired
    private ModelService modelService;

    //获取分析对象
    @RequestMapping("/getModel")
    @ResponseBody
    public List<Map<String,Object>> getModel() {
        PageData pd = this.getPageData();
        List<Map<String,Object>> result = modelService.getModel(pd);
        return result;
    }

    //删除分析对象
    @RequestMapping("/deleteModel")
    @ResponseBody
    public String deleteModel() {
        PageData pd = this.getPageData();
        int m = modelService.deleteModel(pd);
        String result = "";
        if (m > 0){
            result = "删除成功";
        }else{
            result = "删除失败";
        }
        return result;
    }

    //添加分析对象
    @RequestMapping("/addModel")
    @ResponseBody
    public String addModel() {
        PageData pd = this.getPageData();
        int m = modelService.addModel(pd);
        String result = "";
        if (m > 0){
            result = "添加成功";
        }else{
            result = "添加失败";
        }
        return result;
    }





}
